package com.bsoft.rpc.basic.dynamicProxy.cglib;

import com.alibaba.fastjson.JSON;
import com.bsoft.rpc.basic.dynamicProxy.OrgInfo;
import com.bsoft.rpc.basic.dynamicProxy.OrgService;
import net.sf.cglib.proxy.Enhancer;

public class MainTest {
    public static void main(String[] args) {

        Enhancer enhancer = new Enhancer();
        enhancer.setInterfaces(new Class[]{OrgService.class});
        enhancer.setCallback(new CGlibProxyHandler(OrgService.class, "172.0.0.1", 8080));
        OrgService orgService = (OrgService) enhancer.create();

        OrgInfo orgInfo = orgService.getOrgById("bbb");
        System.out.println(JSON.toJSONString(orgInfo));
    }
}
